---
{
	"title": "Base de la BOEW",
	"language": "fr",
	"category": "Autre",
	"categoryfile": "other",
	"description": "Objet principal de la BOEW.",
	"altLangPrefix": "core",
	"dateModified": "2024-07-02"
}
---
<div class="wb-prettify all-pre hide"></div>

<div class="alert alert-warning mrgn-tp-lg">
	<h2>Travail en cours</h2>
	<p>Cette page est un travail en cours.</p>
</div>

<p lang="en"><strong>Needs translation</strong></p>

<section>
	<h2>But</h2>
	<p>Objet principal de la BOEW.</p>
</section>

<section>
	<h2>Exemples</h2>
	<ul>
		<li><a href="../../../demos/core/core-en.html">Exemples anglais</a></li>
		<li><a href="../../../demos/core/core-fr.html">Exemples français</a></li>
	</ul>
</section>

<div lang="en">
<section>
	<h2>Language (<code>wb.lang</code>)</h2>
	<p>WET's language is derived from the <code>html</code> element's <code>lang</code> attribute. A formatted version of the page's language code is stored in the <code>wb.lang</code> variable.</p>
	<p>By default, the variable's value will be derived from the first two characters of the page's language code. If a longer code is specified, it'll be re-used as the variable's value so long as it corresponds to one of WET's built-in languages (i.e. <code>pt-BR</code> for Portuguese [Brazilian] or <code>zh-Hans</code> for Chinese [Simplified]).</p>
	<p>Implementations that want to provide custom i18n files for longer language codes (e.g. <code>en-CA</code>, <code>en-US</code>, etc) can do so by adding <code>data-wb-core</code> and <code>data-lang-long=""</code> attributes to WET's <code>script</code> element.</p>
	<p>WET will also attempt to load an i18n file named after the variable. Plugins won't initialize if the i18n file fails to load.</p>
</section>

<section>
	<h2>Configuration</h2>
	<div class="table-responsive">
		<table class="table">
			<thead>
				<tr>
					<th>Type</th>
					<th>Option</th>
					<th>Description</th>
					<th>How to configure</th>
					<th>Values</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>HTML attribue</td>
					<td><code>data-wb-core</code></td>
					<td>Customizes WET's core variables. Use with other <code>data-*</code> attributes.</td>
					<td>Add a <code>data-wb-core</code> attribute to WET's <code>script</code> element</td>
					<td>None</td>
				</tr>
				<tr>
					<td>HTML attribue</td>
					<td><code>data-lang-long</code></td>
					<td>Extends <code>wb.lang</code>'s support for long language codes (&gt; 2 characters). Use with the <code>data-wb-core</code> attribute.</td>
					<td>Add a <code>data-wb-core</code> attribute to WET's <code>script</code> element</td>
					<td>Space-separated <a href="https://www.rfc-editor.org/info/bcp47" rel="external">BCP 47</a> language codes</td>
				</tr>
			</tbody>
		</table>
	</div>
</section>
<section>
	<h2>JS API</h2>
	<h3>wb.findPotentialPII(str, scope, opts) - Find most common Personal Identifiable Information (PII) in a string </h3>
	<p>Find most common Personal Identifiable Information (PII) in a string and return either the cleaned string either true/false</p>
	<p>This function can have the following parameters</p>
	<ul>
		<li>
			<code>str</code> (required) - string representing the content that needs to be verified
		</li>
		<li>
			<code>scope</code> this parameter can be:
			<ul>
				<li>either a boolean (required) - If passed as true will scrub the content</li>
				<li>either an object (optional) - having the following properties (optional):
					<ul>
						<li>{string} any key name of the default patterns e.g. <code>email</code>, <code>digits</code>, etc. with the value 1. The function will only scrub the content that match the regex of the default patterns passed in this object
						<p>The list of the regular expressions that will be applied by default:</p>
						<ul>
							<li>digits</li>
							<li>passport</li>
							<li>email</li>
							<li>postalCode</li>
							<li>username</li><li>password</li>
						</ul>
						</li>

						<li>{regex} <code>customCase</code> - this param is a regular expression. It will search and replace the values corresponding that pattern</li>
					</ul>
				</li>
			</ul>

		</li>
		<li>
			<code>opts</code> (optional) - the 3rd param of the function is an object that can contain the following properties (optional):
			<ul>
				<li>{boolean} <code>isCustomExclusive</code> - if the value is 1(true), it will scrub only the custom regex if the regex is the only property of the <code>scope</code> object
</li>
				<li>{string} <code>replaceWith</code> - this string will replace the scrubbed content</li>
				<li>{boolean} <code>useFullBlock</code> - if the is value 1(true), it will replace the scrubbed characters with the "█" symbol;</li>
			</ul>
		</li>
	</ul>
	<p>Working example</p>
<pre><code>
wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", true )
</code></pre>
<p>It will return: "email:, phone:" </p>
<pre><code>
	wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", false )
</code></pre>
<p>It will return: <code>true</code> </p>
<pre><code>
wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", { email:1 }{ replaceWith: [REDACTED/CAVIARDÉ] } )
</code></pre>
<p>It will return:"email:[REDACTED/CAVIARDÉ], phone:123 123 1234" </p>
<pre><code>
wb.findPotentialPII( "email:test@test.com, phone:123 123 1234, numéro de cas 12345678", { "customCase":/\b(?:case[\s-]?number[\s\-\\.]?(?:\d{5,10}))|(?:numéro[\s-]?de[\s-]?cas[\s\-\\.]?(?:\d{5,10}))/ig }, { useFullBlock:1})
</code></pre>
<p>It will return: "phone:████████████, email:█████████████, postalCode:██████, ██████████████████████"</p>
</section>

<section>
	<h2>Native DOM event on ready</h2>
	<p>WET-BOEW triggers a native DOM event once all plugins have been initialized. The event is called <code>wet-boew-ready</code>.</p>
	<p>Here is an example of how it can be used:</p>
	<pre><code>document.addEventListener( "wet-boew-ready", function( e ) {
	...code...
});</code></pre>
	<script>
		document.addEventListener( "wet-boew-ready", function( e ) {
			console.log( "DOM event - WET-BOEW is now ready" );
		} );
	</script>
</section>

<section>
	<h2>Source code</h2>
	<p><a href="https://github.com/wet-boew/wet-boew/tree/master/src/core">WET core source code on GitHub</a></p>
</section>
</div>
